#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
    int N;
    cin >> N;
    int min = 1;
    int max = 0;
    
    for(int i = 0; i < N - 1 ; i++)
         min  = min * 10;    
     max = min * 10 -1;
    for(int x = min; x < max+1; x++)
    {
        //cout << x << " ";
        int y = x;
        long sum = 0;
        while(y > 0)
        {
            //cout << x % 10;
            int temp = y % 10;
            long exp = 1;
            for(int i = 0; i < N; i++)
                exp = exp * temp;
            sum  = sum + exp;
            y = y /10;
        };
        if( sum == x )
                cout << x << endl;
        
    }
}
